<?php
namespace Mobile\Controller;
use Think\Controller;
class IndexController extends Controller {
	public function _initialize(){
	
		if(!isMobile()){
			$this->redirect("Home/Index/index");
		}
		$lg=$_GET["lg"];
		if($lg=="logout"){
			session("loginname",null);
		}
		if($_SESSION["loginname"]){
			$headimg = D("user")->where("phone='%s' or mail='%s'",$_SESSION["loginname"],$_SESSION["loginname"])->getField("headimg");
			$serialnumber = D("user")->where("name='%s'",$_SESSION['loginname'])->getField('serialnumber');
			$this->assign("loginname",$_SESSION['loginname']);
			$this->assign("headimg",$headimg);
			$this->assign("logined",1);
		}else{
			$this->assign("logined",0);
		}
	}
	//首页
    public function index(){
    	$homenotice = D("admin")->where("id=1")->getField("homenotice");
    	$noticelist = D("notice")->where("serialnumber='%s'",$serialnumber)->select();
    	$this->assign("noticelist",$noticelist);
    	$this->assign('homenotice',$homenotice);
		$this->display(":index");
    }
    //添加相册
   	public function newalbum(){
   		$this->display(":newAlbum");
   	}
    //用户中心页面
    public function usercenter(){
    	$this->display(":userCenter");
    }
}